//
//  KWallProfileViewController.m
//  Keping
//
//  Created by apple on 2017/12/8.
//  Copyright © 2017年 柯平. All rights reserved.
//

#import "KWallProfileViewController.h"
#import "KWallProfileCell.h"
#import "KBbsTopicsDetailRequest.h"
#import "KStatusRequest.h"
#import <MJRefresh/MJRefresh.h>
#import "KWallDetailViewController.h"

@interface KWallProfileViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, weak) IBOutlet UITableView *tableView;

@end

@implementation KWallProfileViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setUI];
}

- (void)setUI {
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([KWallProfileCell class]) bundle:nil]
         forCellReuseIdentifier:NSStringFromClass([KWallProfileCell class])];
    self.tableView.tableFooterView = [[UIView alloc] init];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.statusLayouts.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 80.0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    KWallProfileCell* cell = [tableView dequeueReusableCellWithIdentifier:[KWallProfileCell className]];
    if (!cell) {
        cell = [[KWallProfileCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[KWallProfileCell className]];
    }
    NSInteger row = indexPath.row;
    cell.statusLayout = [self.statusLayouts objectAtIndex:row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    KWallDetailViewController *detail = [[KWallDetailViewController alloc] init];
    KStatusLayout *statuslayout = [self.statusLayouts objectAtIndex:indexPath.row];
    detail.wallID = statuslayout.status.topicId;
    [self.navigationController pushViewController:detail animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
